#include "day.h"
#include "ui_day.h"

#include <QAbstractButton>
#include <QMessageBox>
#include <QPaintEvent>
#include <QPainter>
#include <QPushButton>
#include <QTime>

Day::Day(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::Day)
{
    ui->setupUi(this);
    this->setGeometry(QRect(350,180,850,550));
    setFixedSize(850,550);

    QPushButton *btn21=new QPushButton("Back",this);
    btn21->resize(160,40);
    btn21->move(670,10);
    connect(btn21,&QPushButton::clicked,this,[=](){
       this->close();
    });

    menu1=new QMenu("New Game",this);
    menu2=new QMenu("Degree",this);

    ui->menuBar->addMenu(menu1);
    ui->menuBar->addMenu(menu2);
    connect(menu1,&QMenu::aboutToShow,this,SLOT(slot_newGame()));

    easy=new QAction("easy",this);
    normal=new QAction("normal",this);
    hard=new QAction("hard",this);
    self=new QAction("self define",this);

    menu2->addAction(easy);
    menu2->addAction(normal);
    menu2->addAction(hard);
    menu2->addAction(self);

    connect(easy,&QAction::triggered,this,SLOT(slot_level(1)));
    connect(normal,&QAction::triggered,this,SLOT(slot_level(2)));
    connect(hard,&QAction::triggered,this,SLOT(slot_level(3)));
    connect(self,&QAction::triggered,this,SLOT(slot_level_self()));

    dialogSelf=new Dialog(this);
    connect(dialogSelf,SIGNAL(dia_test()),this,SLOT(slot_level_self_get()));

    rows = 9;
    cols = 9;
    mine = 10;
    newGame();
}




void Day::slot_level(int a)
{
    if(a==1)
    {
        rows = 9;
        cols = 9;
        mine = 10;
        newGame();
    }
    else if(a==2)
    {
        rows = 16;
        cols = 16;
        mine = 40;
        newGame();
    }
    else
    {
        rows = 16;
        cols = 30;
        mine = 99;
        newGame();
    }
}

Day::~Day()
{
    delete ui;
}
